package com.softa.service.system.impl;

import com.github.pagehelper.ISelect;
import com.github.pagehelper.PageInfo;
import com.softa.dao.mapper.base.SysLogMapper;
import com.softa.dao.mapper.relation.system.SysLogRelationMapper;
import com.softa.service.system.LogService;
import com.softa.dao.model.SysLog;
import com.softa.vo.DataGridRequest;
import com.softa.vo.QueryRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class LogServiceImpl implements LogService {
	
	@Resource
	private SysLogMapper sysLogMapper;
	
	@Resource
	private SysLogRelationMapper sysLogRelationMapper;

	@Override
	public void saveLog(SysLog log) {
		sysLogMapper.insert(log);
	}

	@Override
	public Integer deleteLog(Long id) {
		return sysLogMapper.deleteByPrimaryKey(id);
	}

	@Override
	public PageInfo<SysLog> queryLogByparam(DataGridRequest request, final QueryRequest queryRequest) {
		return request.startPagePlugin().doSelectPageInfo(new ISelect() {
//			@Override
			public void doSelect() {
				sysLogRelationMapper.selectByCondition(queryRequest);
			}
		});
	}

}
